#include <stdio.h>

void main(){
	int s[10],i;
	int *p=s;
	for (i;i<10;i++){
		scanf("%d",&s[i]);
	}
//	scanf("%d %d %d %d %d",&s[0],&s[1],&s[2],&s[3],&s[4]);
	int max=-0x7fffffff,min=0x7fffffff,j=0,k=9,max_i=0,min_i=0;
	for ( j=0;j<10;j++ ){
		if (s[j]>s[k]){
			max   = max>s[j]?max:s[j];
			max_i = max==s[j]?j:max_i;
			min   = min<s[k]?min:s[k];
			min_i = min==s[k]?k:min_i;
		}else{
			max   = max>s[k]?max:s[k];
			max_i = max==s[k]?k:max_i;
			min   = min<s[j]?min:s[j];
			min_i = min==s[j]?j:min_i;
		}
		j++;
		k--;
	}
	i=s[max_i];
	s[max_i]=s[min_i];
	s[min_i]=i;
	for ( i=0;i<10;i++ ){
		printf("%4d",s[i]);
	}
}
